<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;padding: 0px;
        }
        ul,li{
            list-style: none;
        }
        html,body{
            height: 100%;
        }
        #app{
            box-sizing: border-box;
            width: 100%;
            position: fixed;
            bottom: 0px;
        }
        .goods{
            display: flex;
            justify-content: space-between;
            margin: 10px;
        }
        ul{
            margin-top: 20px;
            margin: 10px;
        }
        ul>li{
            display: flex;
            margin-top: 20px;
        }
        ul img{
            width: 40%;
            margin-right: 20px;
        }
        ul .right{
            width: 50%;
        }
        ul .right .bot{
            display: flex;
            justify-content: space-between;
            margin-top: 50px;
            position: relative;
        }
        ul .right .bot>.p3{
            position: absolute;
            bottom: 0px;
            right: 0px;
        }
        .delete{
            margin: 10px;
            width: 100%;
            line-height: 80px;
            text-align: center;
        }
        .goodsNum{
            height: 60px;
            background-color: rgba(0,0,0,.3);
            margin-top: 20px;
            position: relative;
        }
        .goodsNum>span{
            display: inline-block;
            position: absolute;
        }
        .goodsNum>span:nth-child(1){
            top: 20px;
            left: 4px;
            color: #fff;
        }
        .goodsNum>span:nth-child(2){
            top: 20px;
            left: 70px;
            color: #fff;
        }
        .goodsNum>span:nth-child(3){
            display: inline-block;
            width: 100px;
            height: 40px;
            background-color: coral;
            position: absolute;
            bottom: 10px;
            right: 10px;
            border-radius: 5px;
            text-align: center;
            line-height: 40px;
            color: #fff;
        }
        
    </style>
</head>

<body>
    <div id="app">
        <!-- 已选商品 -->
        <div class="goods">
            <h4>已选商品</h4>
            <button @click="clear">清空</button>
        </div>
        <!-- 商品信息 -->
        <ul>
            <li v-for="(item,index) in listArr">
                <img :src="item.pic" alt="">
                <div class="right">
                    <p class="p1">{{item.name}}</p>
                    <div class="bot">
                        <p class="p2">
                            <span>{{item.price}}<del>{{item.dprice}}</del></span>
                        </p>
                        <p class="p3">
                            <input type="button" value="-" @click="sub(item)">
                            <span>{{item.num}}</span>
                            <input type="button" value="+" @click="add(item)">
                        </p>
                    </div>
                </div>
            </li>
        </ul>
        <!--  -->
        <div v-show="listArr.length == 0" class="delete">商品空空如也，快去逛逛吧</div>
        <!-- 统计商品数量 -->
        <div class="goodsNum">
            <span>总数:{{totalNum}}</span>
            <span>总价:{{totalPrice}}</span>
            <span>去结算</span>
        </div>
    </div>
</body>
</html>
<script src="../vue-2.5.21.js"></script>
<script src="./01_shopCart.js"></script>